<?php 
 include_once dirname(__FILE__)."/config.php";
 class aa_type_candidature_principal{
		 protected $_resultrequest;
		 protected $_cnn;
		 protected $_code_type_cand;
		 protected $_lib_candidature;
		 public function get_name_table(){ return "aa_type_candidature";}
		 public function get_name_code_type_cand(){ return "code_type_cand";}
		 public function get_name_lib_candidature(){ return "lib_candidature";}
		 public function set_code_type_cand($parametre){  $this->_code_type_cand=$parametre;}	
		 public function set_lib_candidature($parametre){  $this->_lib_candidature=$parametre;}	
		 public function get_resultrequest(){ return $this->_resultrequest;}
		 public function get_code_type_cand(){ return $this->_code_type_cand;}
		 public function get_lib_candidature(){ return $this->_lib_candidature;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 aa_type_candidature(
			lib_candidature)
 VALUES(
			'".$this->_lib_candidature."')";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_lib_candidature)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
lib_candidature='".$this->_lib_candidature."'";
}
$sql="UPDATE 
aa_type_candidature SET 
 ".$sql."
								WHERE 1=1  AND code_type_cand ='".$this->_code_type_cand."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
aa_type_candidature 
 
									WHERE 1=1  AND code_type_cand ='".$this->_code_type_cand."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
aa_type_candidature ";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_type_cand,
		lib_candidature
 FROM 
 aa_type_candidature";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function countRowInTable($constraint="")
{

$sql=" SELECT 
  COUNT(*) AS total 
 FROM 
 aa_type_candidature ";
	$this->_resultrequest=$this->_cnn->query($sql);
$donnees_total=mysql_fetch_assoc($this->_resultrequest);
return $donnees_total['total'];
}
public function fetch_object(){
$row=mysql_fetch_object($this->_resultrequest);
 if($this->_resultrequest){
 if($row){
		$this->_code_type_cand=$row->code_type_cand;
		$this->_lib_candidature=$row->lib_candidature;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>